﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using DigitalRubyShared;
public class LevelBig2Small : MonoBehaviour
{
    public GameObject loveObject;
    private ScaleGestureRecognizer scaleGesture;

    public GameLevelItem gameLevelItem;
    // Start is called before the first frame update
    void Start()
    {
        scaleGesture = new ScaleGestureRecognizer();
        scaleGesture.StateUpdated += RotateGestureCallback;
        FingersScript.Instance.AddGesture(scaleGesture);
    }

    private void OnDisable()
    {
        if (null != scaleGesture)
        {
            scaleGesture.StateUpdated -= RotateGestureCallback;
            Debug.LogError("去掉回调");

        }
    }

    // Update is called once per frame
    void Update()
    {


    }

    private void RotateGestureCallback(DigitalRubyShared.GestureRecognizer gesture)
    {

        Debug.Log(gesture.State.ToString());
        if (gesture.State == GestureRecognizerState.Executing)
        {
            if (scaleGesture.ScaleMultiplier < 1)
            {
                loveObject.transform.localScale *= scaleGesture.ScaleMultiplier;
            }
        }

        if (loveObject.transform.localScale.x < 1)
        {
            loveObject.transform.localScale = Vector3.one;
            FingersScript.Instance.RemoveGesture(scaleGesture);
            gameLevelItem.TriggerResult(true);
        }



    }

}
